package semant.firstpass;

import errors.ErrorEchoer;
import semant.Env;
import syntaxtree.Program;
import syntaxtree.VisitorAdapter;

public final class ProgramHandler extends VisitorAdapter
{
	private Env result;
	
	private ProgramHandler(ErrorEchoer err)
	{
		super();
	
		result = new Env(err);
	}
	
	public static Env firstPass(ErrorEchoer err, Program p)
	{
		ProgramHandler h = new ProgramHandler(err);
		
		p.accept(h);
		
		return h.result;
	}
	
	@Override
	public void visit(Program node)
	{
		MainClassHandler.firstPass(result, node.mainClass);
		
		ClassHandler.firstPass(result, node.classList);
	}
}
